﻿@model OMS.Models.EditOrderModel
@{
    ViewBag.Title = "Edit";
    
}

@using (Html.BeginForm())
{
    <div>
        This page is appointed for order managing<br /><br />
        
    </div>
    <div>
        <div style="margin-bottom: 5px;">
            <br />
       
        
            @Html.DropDownList("selectItemOnPage", new SelectList(new string[] {"show 10 lines", "show 25 lines"}), new {style = "float: right;"})
        
        </div>
        <table class="rounded-corner">
            <thead> 
                <tr>
                    <th class="rounded-company">@Html.ActionLink("Id", "Index")</th>
                    <th>@Html.ActionLink("Item Name", "Index")</th>
                    <th>@Html.ActionLink("Item Description", "Index")</th>
                    <th>@Html.ActionLink("Dimension", "Index")</th>
                    <th>@Html.ActionLink("Price", "Index")</th>
                    <th>@Html.ActionLink("Quantity", "Index")</th>
                    <th>@Html.ActionLink("Price per Line", "Index")</th>

                </tr>
            </thead>
            @foreach (var c in ViewBag.orderDetails)
            {
                <tr>
                    <td>@c.ItemDimension.Item.ItemId</td>
                    <td>@c.ItemDimension.Item.Name</td>
                    <td>@c.ItemDimension.Item.Name</td>
                    <td></td>
                    <td>@c.Price</td>
                    <td>@c.Count</td>
                    <td>@( c.Count*(float) c.Price)</td>
                    @*<td>@Html.ActionLink("Edit","Index")</td>
                <td>@Html.ActionLink("Delete","Index")</td>*@
                </tr>

            }

        </table>
        @Html.Partial("~/Views/Shared/_PaginationPartial.cshtml")
    </div>
    <div style="margin-top: 20px;"> 
        <div class="panel-text-left">
            Totals
        </div>
        <div class="panel-text-center">
            Status
        </div>
    </div>
    <div id="info">

        <div class="totals-info label">
            <table class="ordering-table">
                <tr>
                    <td>Order Number</td>
                    <td>@ViewBag.order.OrderId</td>
                </tr>
                <tr>
                    <td>Customer</td>
                    <td>@ViewBag.order.user.LoginName</td>
                </tr>
                <tr>
                    <td>Total Price</td>
                    <td>@(ViewBag.order.TotalPrice + " $")</td>
                </tr>
                <tr>
                    <td>Total Number of Items</td>
                    <td>@ViewBag.orderDetails.Count</td>
                </tr>
                <tr>
                    <td>Date of Ordering</td>
                    <td>@ViewBag.order.DateOfOrdering</td>
                </tr>
                <tr>
                    <td>Preferable Delivery Date</td>
                    <td>@ViewBag.order.PreferibleDeliveryDate</td>
                </tr>

                <tr>
                    <td>Assignee</td>
                    <td>@ViewBag.order.Assigned</td>
                </tr>
            </table>
        </div>
        <div class="status-order  label">
            <table class="ordering-table" >
                <tr>
                    <td>Accepted</td>
                    <td>@Html.CheckBoxFor(m => m.Accepted,new{@id="checkBoxAccepted"})</td>
                </tr>
                <tr>
                    <td>Gift</td>
                    <td>@Html.CheckBoxFor(m => m.Gift, new{@id="checkBoxGift",@disabled = "disabled"})</td>
                </tr>

                 <tr>
                    <td>Delivery Date</td>
                     <td>@Html.TextBoxFor(m => m.DeliveryDate, new { @id = "datepicker1", @class="border admin-drop-list"}) </td>

                </tr>
                    
                <tr>
                    <td>Delivered</td>
                    <td>@Html.CheckBoxFor(m => m.Delivered, new{@id="checkBoxDelivered", @disabled= "disabled"})</td>
                </tr>
                   
                <tr>
                    <td></td>

                </tr>
            </table>

        </div>
    </div>
    <div style="text-align: right;">
        <button type="submit" name="action" value="Create" class="buttons-blue">Save</button>
            
        <button type="button" name="action" onclick=" location.href = 'Index' " class="buttons-red">Cancel</button>
                
    </div>


    <script type="text/javascript">
        $(function () {
           $("#datepicker1").datepicker();
        });

        $(function () {
            $(window).load(function () {
                check();
                checkInput();
            });
        });

        function check() {
            $("#checkBoxAccepted").click(function () {// alert('Check');
                checkInput();
            });
        }
        function checkInput() {//alert('CheckInp');
            if ($("#checkBoxAccepted").is(":checked")) {
                $("#checkBoxGift, #checkBoxDelivered, #datepicker1").attr("disabled", false);
            }
            else {
                $("#checkBoxGift, #checkBoxDelivered, #datepicker1").attr("disabled", true);
                $("#checkBoxGift, #checkBoxDelivered").attr("checked", false);
                $("#datepicker1").val('');
            }
        }
    
    </script>
  
}
